﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Reporting.API.Application.Commands.InvoiceManagements;
using Reporting.API.Application.Commands.Productionorders;
using Reporting.Errorcode;

namespace Reporting.API.Controllers
{
    /// <summary>
    /// 开票  --API
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class InvoiceManagementController : ControllerBase
    {
        private readonly IMediator _mediator;

        public InvoiceManagementController(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 新增--开票
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult> AddInvoiceManagement([FromBody] AddInvoiceManagementCommand request)
        {
            return await _mediator.Send(request);
        }


        /// <summary>
        /// 显示所有开票
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult> GetInvoiceManagement([FromQuery] GetInvoiceManagementCommand request)
        {
            return await _mediator.Send(request);
        }

        /// <summary>
        /// 修改开票
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult> UpdInvoiceManagement(UpdateInvoiceManagementCommand request)
        {
            return await _mediator.Send(request);
        }

        /// <summary>
        /// 删除 开票
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<ApiResult> DelInvoiceManagement([FromQuery]DeleteInvoiceManagementCommand request)
        {
            return await _mediator.Send(request);
        }

        /// <summary>
        /// ID查询 开票信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult> GetIDInvoiceManagement([FromQuery] GetIDInvoiceManagementCommand request)
        {
            return await _mediator.Send(request);
        }
    }
}
